﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace LoginNew
{
    public partial class Comfirmation : System.Web.UI.Page
    {


        protected void Page_Load(object sender, EventArgs e)
        {

            int id = 0;
            //create connection

            string conn = ConfigurationManager.ConnectionStrings["SqlProviderCon"].ToString();
            SqlConnection con = new SqlConnection(conn);
            SqlCommand cmd1 = new SqlCommand();
            cmd1.CommandText = "select Max(UserID) from [CocShopUserInfor].[dbo].[UserInfor]";
            cmd1.Connection = con;
            SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
            DataTable tb1 = new DataTable();
            da1.Fill(tb1);
            foreach (DataRow row in tb1.Rows)
            {
                id = int.Parse(row[0].ToString());

            }
            SqlCommand cmd = new SqlCommand(); //Create query command
            //Set command text
            cmd.CommandText = " SELECT * FROM [CocShopUserInfor].[dbo].[UserInfor] where userid  = " + id;

            cmd.Connection = con; //Set connection
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            DataTable tb = new DataTable();
            da.Fill(tb);    //Fill the datatable

            //Show data from datatable
            foreach (DataRow row in tb.Rows)
            {
                txtfirstname.Text = row[1].ToString();
                txtlastname.Text = row[2].ToString();
                txtphone.Text = row[3].ToString();
                txtemail.Text = row[4].ToString();
                txtusername.Text = row[5].ToString();
                txtpassword.Text = row[6].ToString();
            }
        }


        protected void backButton_Click(object sender, EventArgs e)
        {
            Response.Redirect("Register.aspx");
        }

        protected void finishButton_Click(object sender, EventArgs e)
        {
            Response.Redirect("Finish.aspx");
        }
    }
}